import request from '@/utils/request'

// 查询我的出租列表
export const getMyHouseList = () => {
  return request({
    url: 'user/houses'
  })
}

// 搜索小区
export const searchCommunity = ({ id, name }) => {
  return request({
    url: 'area/community',
    params: {
      id,
      name
    }
  })
}

// 上传图片
export const uploadImage = files => {
  const formData = new FormData()

  files.forEach(item => {
    formData.append('file', item.file)
  })

  return request({
    url: '/houses/image',
    method: 'POST',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data: formData
  })
}

// 发布房源
export const publishHouse = data => {
  return request({
    url: '/user/houses',
    method: 'POST',
    data
  })
}
